<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<c:set var="title">经费预算表</c:set>
<c:if test="${not empty param.title }"><c:set var="title">${param.title }</c:set></c:if>

<div class="t_bar">
	 主要知识产权证明目录（限10条）
</div>
<p><strong>注意</strong>：</p>
<p>1．知识产权类别限20个字；</p>
<p>2．知识产权具体名称限40个字；</p>
<p>3．授权号限20个字；</p>
<p>4．证书编号限20个字；</p>
<p>5．权利人限50个字；</p>
<p>6．发明人限50个字；</p>
<table  id="knowledge" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;table-layout: fixed;" >
	<col width="5%" />
	<col width="5%" />
	<col width="10%" />
	<col width="10%" />
	<col width="10%" />
	<col width="10%" />
	<col width="14%" />
	<col width="10%" />
	<col width="13%" />
	<col width="13%" />
	<thead >
			<tr style="border:1px solid #B7D1E6">
				<th class="TblHead" align="center" >选择</th>
				<th class="TblHead" align="center" >序号</th>
				<th class="TblHead" align="center" >知识产权类别</th> 
				<th class="TblHead" align="center" >知识产权具体名称</th> 
		     	<th class="TblHead" align="center" >国家（地区）</th> 
				<th class="TblHead" align="center" >授权号</th> 
				<th class="TblHead" align="center" >授权日期</th> 
				<th class="TblHead" align="center" >证书编号</th> 
				<th class="TblHead" align="center" >权利人</th> 
				<th class="TblHead" align="center" >发明人</th> 
			</tr>
	
	</thead>
	<tbody id="tab">
	<tr style="display:none" align="center">
		<td align="center">
			<input type="radio" class="radiobutton" name="knowledge" >
		</td>
		<td align="center">
			<span name="knowledge|list[0]@seq_no" >[index]</span> 
		</td>
		<td align="center">
			<input type="text" name="knowledge|list[0]|knowledge_type" label="知识产权类别" class=" required input_text " maxlength="20" style="width:80%"/>
		</td>
		<td align="center">
			<input type="text" name="knowledge|list[0]|knowledge_name" label="知识产权具体名称" class=" required input_text " maxlength="40" style="width:80%"/>
		</td>
		<td align="center">
			<input type="text" name="knowledge|list[0]|country_area"   label="国家（地区）" style="width:80%" class=" input_text required" />
		</td>
		<td align="center">
			<input type="text" name="knowledge|list[0]|approve_no" id="approve_no[0]" maxlength="20"  label="授权号"  style="width:80%" class=" input_text required" />
		</td>
		<td align="center">
			<input id="approve_date_[0]" name="knowledge|list[0]|approve_date"  class=" required date  dateCompare:nowDate" label="授权日期"  size="10%;"/>
		</td> 
		<td align="center">
			<input type="text" name="knowledge|list[0]|certificate_no"  maxlength="20" label="证书编号"   style=" width:80%" class=" input_text required" />
		</td> 
		<td align="center">
			<input type="text" name="knowledge|list[0]|right_psn" maxlength="50"  label="权利人"   style=" width:80%" class=" input_text required" />
		</td> 
		<td align="center">
			<input type="text" name="knowledge|list[0]|invent_psn"  maxlength="50" label="发明人"   style=" width:80%" class=" input_text required" />
		</td> 
	</tr>
	
	<c:set value="0" var="index" scope="page"/>
	<x:forEach select="$xmlData/data/knowledge/list" var="list">
	
	<c:choose>
		<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
		<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
	</c:choose>
	<tr align="center">
		<td align="center">
			<input type="radio" class="radiobutton" name="knowledge" >
		</td>
		<td align="center">
			<span name="knowledge/list[${flag}${index}]@seq_no" ><x:out select="$list/@seq_no"/></span> 
		</td>
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/knowledge_type"  value="<x:out select="$list/knowledge_type"/>"   label="知识产权类别" class=" required input_text " maxlength="20" style="width:80%"/>
		</td>
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/knowledge_name"  value="<x:out select="$list/knowledge_name"/>"   label="知识产权具体名称" class=" required input_text " maxlength="40" style="width:80%"/>
		</td>
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/country_area"  value="<x:out select="$list/country_area"/>"   label="国家（地区）" class=" required input_text " maxlength="20" style="width:80%"/>
		</td>
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/approve_no" id="approve_no[${flag}${index}]"  value="<x:out select="$list/approve_no"/>"   label="授权号" class=" required input_text " maxlength="20" style="width:80%"/>
		</td>
		<td align="center">
			<c:set var="approve_date" scope="page"><x:out select="$list/approve_date"/></c:set>
			<cpt:date id="approve_date" name="knowledge/list[${flag}${index}]/approve_date" value="${approve_date}" className=" required date  dateCompare:nowDate" label="授权日期"  size="10%;" ></cpt:date>
		</td>
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/certificate_no"  value="<x:out select="$list/certificate_no"/>"   label="证书编号" class=" required input_text " maxlength="20" style="width:80%"/>
		</td>	
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/right_psn"  value="<x:out select="$list/right_psn"/>" maxlength="50"  label="权利人" class=" required input_text "  style="width:80%"/>
		</td>	
		<td align="center">
			<input type="text" name="knowledge/list[${flag}${index}]/invent_psn"  value="<x:out select="$list/invent_psn"/>" maxlength="50"  label="发明人"   style=" width:80%" class=" input_text required" />
		</td> 
	</tr>
	<c:set value="${index+1}" var="index" scope="page"/>
	</x:forEach>
	<script type="text/javascript">
		showAllDateTag("knowledge");
	</script>
</tbody>
</table>
<table width="98%" align="center" border="0">
	<tr style="border: 0"><td style="border: 0">
	<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('knowledge',10,'主要知识产权证明目录最多只能添加10条')){addNewRow('knowledge');showDateTag('knowledge');try{top.resizeFrame();}catch(e){};}">
	<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev2('knowledge','knowledge')">
	<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext2('knowledge','knowledge')">
	<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('knowledge','主要知识产权证明目录')">
	</td></tr>
</table>	


<script type="text/javascript">
	
	/**
	 * 上移行
	 * @param tblId
	 * @returns {Boolean}
	 */
	function movePrev2(tblId,selName) {
		if (!selName)
			selName = "";
		if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
			scmWarn(irisNotes.prevWarn);
			return false;
		}
		if ($("#" + tblId + " tr").length <= 2)
			return false;
		var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
				.parents("tr").first();// 取得被选中的行
		var trPrev = trChecked.prev();// 取得上一行
		var index = trChecked.get(0).rowIndex;// 获得行号
		if (index <= 2) {// 如果是第一行
			scmWarn(irisNotes.tabelMoveWarn1);
			return false;
		}
		//trChecked.remove();
		trPrev.before(trChecked);
		trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
		refreshRowINdex22(tblId);
	}

	/**
	 * 下移行
	 * @param tblId
	 * @returns {Boolean}
	 */
	function moveNext2(tblId,selName) {
		if (!selName)
			selName = "";
		if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
			scmWarn(irisNotes.nextWarn);
			return false;
		}
		if ($("#" + tblId + " tr").length <= 2) {
			return false;
		}
		var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
				.parents("tr").first();// 取得被选中的行
		var trNext = trChecked.next();
		var index = trChecked.get(0).rowIndex;// 获得行号
		if (index == $("#" + tblId + " tr").length - 1) {// 如果是第一行
			scmWarn(irisNotes.tabelMoveWarn2);
			return false;
		}
		//trChecked.remove();
		trNext.after(trChecked);
		trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
		refreshRowINdex22(tblId);
	}

	/**
	 * 重新计算行号
	 * @param tblId
	 */
	function refreshRowINdex22(tblId){
		 //重新计算行号
		  $("#"+tblId+" tr").each(function(){
			   var seq=$(this).get(0).rowIndex;//获得行数
			   if(seq>1){//如果有行  显示时display行不计入类，故只减1
				   seq=seq-1;
				   var seq_no=$(this).find("[name$='seq_no']");
				   if(seq_no.is("span"))
					   seq_no.html(seq);
				   else
					   seq_no.val(seq);
				   
				   seq=""+(seq-1);
				   if(seq.length==1)
					   seq="0"+seq;
				  //替换相应的name参数的seq
				  $(this).find("input,span,textarea,select").each(function(){
					   var name=$(this).attr("name");
					   if(name!=null&&name!=""){
						   name=name.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("name",name);
					   }
					   var id=$(this).attr("id");
					   if(id!=null&&id!=""){
						   id=id.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("id",id);
						   id=id.replace(/\d+/g,""+seq+"");
						   $(this).attr("id",id);
					   }
					   var className=$(this).attr("class");
					   if(className!=null&&className!=""){
						   className=className.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("class",className);
					   }
				   });
			   }
			 }
		  );

	}
	
	
	/**
	 * 删除一行
	 * @param radioId 
	 */
	function deleteSelectedRow2(tableId,message,nummin,warnMsg,selName){
		if(!selName)selName="";
		var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
		if(nummin==null)
			nummin=0;
		var length=tr.length;
		if(tr.length==0)
			tr=$("#"+tableId+" tr").filter(":last");
		else if(tr.length>1)
			tr=tr.first();

		if(tr.get(0).rowIndex-1==nummin){
			scmWarn(irisNotes.delWarn1);
			return false;
		}
		if(length==0){
			
				scmWarn(irisNotes.delWarn2);
			
			return false;
		}
		  if(!confirm(messageTip.deleteTip+message+"？"))
			  return false;
		  tr.remove();
		  refreshRowINdex22(tableId);
		  return true;
		  setSubmitOrg() ;
	}
	</script>
